// 商品列表显示

var shopCar = document.querySelector(".bar-shopCar")
var navCar = document.querySelector(".bar-menu")

shopCar.onmouseover = function () {
    navCar.style.display = 'block'
}

shopCar.onmouseout = function () {
    navCar.style.display = 'none'
}



// 搜索框选中

var selectIpt = document.querySelector(".wrap-select input")
var selectA = document.querySelector(".wrap-select a")

// 获得焦点
selectIpt.onfocus = function () {
    selectIpt.style.border = '1px solid #ff6700'
    selectA.style.border = '1px solid #ff6700'
}

// 失去焦点
selectIpt.onblur = function () {
    selectIpt.style.border = '1px solid #b0b0b0'
    selectA.style.border = '1px solid #b0b0b0'
}


// 导航栏鼠标移动下拉效果

// 获得下拉列表
var barContent = document.querySelector(".bar-content")

// 获得导航栏元素
var obtainedTitle = document.querySelector(".spanli1")

obtainedTitle.onmouseover = function () {
    barContent.style.display = 'block'
}

barContent.onmouseover = function () {
    barContent.style.display = 'block'
}

obtainedTitle.onmouseout = function () {
    barContent.style.display = 'none'
}
barContent.onmouseout = function () {
    barContent.style.display = 'none'
}



// 轮播图列表展示

// 获得轮播图列表
var siteCategoryList = document.querySelector('.site-category-list')

// 获得商品列表
var siteCategory = document.querySelector('.site-category ul li a:nth-child(1)')

siteCategory.onmouseover = function () {
    siteCategoryList.style.display = 'block'
}

siteCategoryList.onmouseover = function () {
    siteCategoryList.style.display = 'block'
}

siteCategory.onmouseout = function () {
    siteCategoryList.style.display = 'none'
}

siteCategoryList.onmouseout = function () {
    siteCategoryList.style.display = 'none'
}

// 固定列表（滚轮滚动出现回顶部）

// 获得滚轮滚动距离
var scrrolY
// 获得回到顶部标签
var goBack = document.querySelector('.item:last-child')
addEventListener('scroll', () => {
    scrrolY = document.documentElement.scrollTop
    if (scrrolY > 1200) {
        goBack.style.display = 'block';
    } else {
        goBack.style.display = 'none';
    }
})

// 回到顶部
addEventListener('click', () => {
    scrollTo(0, 0)
})




// 智能穿戴列表切换效果

// 获得耳机标签
var headsetLi = document.querySelector('.tab-list li:nth-child(1)')

// 获得穿戴标签
var wearLi = document.querySelector('.tab-list li:nth-child(2)')

// 右侧商品列表（更改前）
var rightPhotoOne = document.querySelector('.home-brick-box:nth-child(2) .row .right-photo:nth-child(2)')

// 右侧商品列表（更改后）
var rightPhotoSwitchOne = document.querySelector('.home-brick-box:nth-child(2) .row .right-photo:nth-child(3)')

headsetLi.onmouseover = () => {
    headsetLi.classList.add("active")
    rightPhotoOne.style.display = 'block'
    wearLi.classList.remove("active")
    rightPhotoSwitchOne.style.display = 'none'
}

wearLi.onmouseover = () => {
    headsetLi.classList.remove("active")
    rightPhotoOne.style.display = 'none'
    wearLi.classList.add("active")
    rightPhotoSwitchOne.style.display = 'block'
}


// 笔记本 | 平板列表切换效果

// // 获得笔记本标签
// var notebookLi = document.querySelector('.tab-list:nth-of-type(2) li:nth-child(3)')

// // 获得平板标签
// var ipadLi = document.querySelector('.tab-list:nth-of-type(2) li:nth-child(4)')

// // 右侧商品列表（更改前）
// var rightPhotoTwo = document.querySelector('.home-brick-box:nth-child(3) .row .right-photo:nth-child(2)')

// // 右侧商品列表（更改后）
// var rightPhotoSwitchTwo = document.querySelector('.home-brick-box:nth-child(3) .row .right-photo:nth-child(3)')

// headsetLi.onmouseover = () => {
//     headsetLi.classList.add("active")
//     rightPhotoTwo.style.display = 'block'
//     wearLi.classList.remove("active")
//     rightPhotoSwitchTwo.style.display = 'none'
// }

// wearLi.onmouseover = () => {
//     headsetLi.classList.remove("active")
//     rightPhotoTwo.style.display = 'none'
//     wearLi.classList.add("active")
//     rightPhotoSwitchTwo.style.display = 'block'
// }








// 底部小图切换

var img1 = document.querySelector('.img1');
var img2 = document.querySelector('.img2');
var isImg1Visible = true;
var timer;

// 页面加载完成后开始计时器
window.onload = function () {
    startTimer();
}

function startTimer() {
    timer = setInterval(switchImage, 2000); // 每2秒切换一次图片
}

function switchImage() {
    if (isImg1Visible) {
        img1.style.display = 'none';
        img2.style.display = 'block';
        isImg1Visible = false;
    } else {
        img1.style.display = 'block';
        img2.style.display = 'none';
        isImg1Visible = true;
    }
}



